<template>
	<div>
		<!-- 搜索框 -->
		<u--input placeholder="前置图标" prefixIcon="search" inputAlign="center"
			prefixIconStyle="font-size: 22px;color: #909399"></u--input>


		<!-- 轮播图 -->
		<view class="banner-list">
			<swiper circular :indicator-dots="true" :autoplay="true" :interval="2000" :duration="500">
				<swiper-item v-for="(item,index) in banners" :key="index">
					<image :src="item.src" mode=""></image>
				</swiper-item>
			</swiper>
		</view>

		<!-- //导航 -->
		<view class="nav">
			<a href="#" v-for="(item,index) in nav" :key="item.name">
				<img :src="item.src" @click="addname(item.name)" alt="">
				<view class="zi">
					{{item.name}}
				</view>
			</a>
		</view>
		<view class="list">
			<view class="box" v-for="item in youhui" :key="item.id">
				<view class="left">
					<span>{{item.price}}</span>
					<span>{{item.value.title}}</span>
				</view>
				<view class="right">
					<span>领取</span>
				</view>
			</view>
		</view>

		<view class="s1">

		</view>
		<!-- 拼团 -->
		<view class="title">
			<span>拼团</span>
		</view>
		<view class="pt">
			<scroll-view class="scroll-view_H" scroll-x="true">
				<view id="demo1" class="scroll-view-item_H uni-bg-red">
					<view class="box" v-for="item in pt" :key="item.goods_id">
						<view class="image">
							<img :src="item.cover" alt="">
						</view>
						<view class="value">
							<span>{{item.title}}</span>
							<view class="value1">
								<span style="color: red; font-size:30px">￥{{item.price}}</span>
								<span>￥{{item.t_price}}</span>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>

		<view class="s1">

		</view>

		<view class="s2">
			<span>最新列表</span>
			<span class="span" @click="gengduo">查看更多</span>
		</view>

		<!-- 最近列表 -->
		<view class="list-item" v-for="item in zuixin" :key="item.id">
			<view class="left">
				<img :src="item.cover" alt="">
			</view>
			<view class="right">
				<span>{{item.title}}</span>
				<view class="item">
					<span style="font-size: 40px;color: red;">￥{{item.t_price}}</span>
					<span style="font-size: 25px;color: gray;">￥{{item.price}}</span>
				</view>
			</view>
		</view>

		<!-- 最后一张图 -->
		<view class="image-banner">
			<img :src="bannerimage" alt="">
		</view>

	</div>
</template>

<script>
	import {
		bannerList,
		zuixinList,
		youhuilist,
		pituanList
	} from "@/api/user.js"
	export default {
		data() {
			return {
				banners: [], //轮播图
				nav: [], //导航栏
				youhui: [], //优惠价
				pt: [], //拼团
				zuixin: [], //最新列表
				bannerimage: []
			}
		},
		onLoad() {
			this.banner()
			this.youhuijia()
			this.pituan()
		},
		methods: {
			//跳转到学习
			addname(name) {
				if (name == "考试") {
					// uni.navigateTo({
					// 	url:"/pages/test-list/test-list"
					// });
					this.$router.push('/pages/test-list/test-list')
				}else if(name=="电子书"){
					this.$router.push('/pages/book-list/book-list')
				}
			},
			//跳转到更多
			gengduo() {
				uni.navigateTo({
					url: "/pages/list/list"
				})
			},
			async banner() {
				let res = await bannerList();
				this.banners = res.data[1].data //轮播图
				this.nav = res.data[2].data
				console.log(res, 1);
				this.bannerimage = res.data[6].data
				this.zuixin = res.data[5].data

			},
			//优惠券
			async youhuijia() {
				let res = await youhuilist()
				console.log(res);
				this.youhui = res.data
			},
			//拼团
			async pituan() {
				let res = await pituanList()
				console.log(res);
				this.pt = res.data.rows
			}
		},
	}
</script>

<style scoped lang="scss">
	.list {
		width: 100%;
		height: 150rpx;
		background-color: white;
		margin-left: 20px;
		overflow: auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-left: 20rpx;

		.box {
			width: 100%;
			height: 130rpx;
			background-color: yellow;
			display: flex;
			margin-left: 20rpx;

			.left {
				width: 415rpx;
				height: 100%;
				background-color: #d39e00;
				display: flex;
				justify-content: center;
				align-items: center;
				flex-direction: column;
				border-right: 4px dashed white;


				span {
					font-size: 30rpx;
					color: white;
					font-weight: bold;

				}
			}

			.right {
				width: 100rpx;
				height: 100%;
				background-color: #ffc107;
				display: flex;
				justify-content: center;
				align-items: center;

				span {
					font-size: 24rpx;
				}
			}
		}
	}



	.scroll-view-item_H {
		display: inline-block;

	}

	.image-banner {
		width: 750rpx;
		height: 300rpx;

		img {
			width: 750rpx;
			height: 300rpx;
		}
	}

	.list-item {
		width: 750rpx;
		height: 180rpx;
		background-color: white;
		display: flex;
		margin-top: 20rpx;

		.right {
			width: 65%;
			height: 180rpx;
			background-color: white;

			span {
				font-size: 40rpx;

			}

			.item {
				display: flex;

				span {
					margin-top: 30rpx;
				}
			}
		}

		.left {
			width: 45%;
			height: 180rpx;
			background-color: white;
			display: flex;
			align-items: center;
			justify-content: center;

			img {
				width: 302rpx;
				height: 166rpx;
			}
		}
	}

	.s2 {
		width: 100%;
		height: 70rpx;
		background-color: white;
		display: flex;
		justify-content: space-between;
		padding-left: 20rpx;
		padding-right: 20rpx;
		align-items: center;
		font-size: 30rpx;
		font-weight: bold;

		.span {
			font-size: 20rpx;
			color: #a9a5a0;
		}

	}

	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
		height: 100%;
		background-color: white;
	}

	#demo1 {
		width: 100%;
		height: 100%;
		background-color: white;
		display: flex;

		.box {
			width: 100%;
			height: 100%;
			background-color: white;
			display: flex;
			flex-direction: column;
			margin-left: 20px;

			.value {
				font-size: 28rpx;
			}

			.image {
				width: 337rpx;
				height: 170rpx;
				background-color: white;

				img {
					width: 100%;
					height: 100%;
				}
			}

		}
	}



	.scroll-view-item_H {
		display: inline-block;

	}



	.pt {
		width: 100%;
		height: 240rpx;
		background-color: yellow;

	}

	.title {
		width: 100%;
		height: 58rpx;
		background-color: white;
		display: flex;
		align-items: center;

		span {
			padding-left: 20rpx;
			font-size: 30rpx;
			font-weight: bold;
			color: black;
		}
	}

	// 优惠券
	.m-tab {}

	* {
		box-sizing: border-box;
	}

	.s1 {
		width: 100%;
		height: 15px;
		background-color: #F5F5F3;
	}



	.box {
		width: 100%;
		height: 150px;
		background-color: yellow;

		.list {
			width: 80%;
			height: 100%;
			background-color: aqua;
			margin-left: 20px;

			.item {
				width: 100%;
				height: 100%;
				background-color: beige;
				display: flex;

				.left {
					width: 80%;
					height: 100%;
					background-color: pink;
					display: flex;
					justify-content: center;
					align-items: center;
					flex-direction: column;
					border-right: 4px dashed white;

					span {
						font-size: 30px;
						color: white;
						font-weight: bold;
					}
				}

				.right {
					width: 20%;
					height: 100%;
					background-color: blue;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 30px;
					color: white;
					font-weight: bold;
				}
			}
		}

	}



	.nav {
		width: 100%;
		height: 372px;
		background-color: white;
		display: flex;
		justify-content: center;
		justify-content: space-around;
		align-items: center;
		flex-wrap: wrap;

		a {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			width: 25%;
			height: 50%;
			background-color: white;
			color: black;
			text-decoration: none;

			.zi {
				font-size: 25px;
				margin-top: 10px;

			}
		}

		a img {
			width: 86px;
			height: 86px;
		}
	}

	.banner-list {
		width: 100%;
		height: 307px;
		background-color: white;

		swiper {
			width: 100%;
			height: 100%;
		}

		swiper-item {
			width: 100%;
			height: 100%;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}
</style>
